package com.skytech.tax.customsdatawarehouse.singlewindow.processtrade.books.resource;

import com.skytech.tax.customsdatawarehouse.singlewindow.processtrade.books.domain.service.BooksService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Lianhong
 * @since 2021/11/11
 */
@RestController
@RequestMapping("/single-window/process-trade/books")
public class BooksResource {

    @Resource
    private BooksService booksService;

    /**
     * 保存加工贸易账册
     *
     * @param books 加工贸易账册
     */
    @PostMapping
    public String saveBooks(@RequestBody String books) {
        return booksService.save(books);
    }

    /**
     * 查询加工贸易账册明细
     *
     * @param seqNo 账册编号
     */
    @GetMapping("/{seqNo}")
    public String details(@PathVariable String seqNo) {
        return booksService.details(seqNo);
    }


    /**
     * 删除加工贸易账册
     *
     * @param seqNo 账册编号
     */
    @DeleteMapping("{seqNo}")
    public void remove(@PathVariable String seqNo) {
        booksService.remove(seqNo);
    }

    /**
     * 判断是否存在加工贸易账册
     *
     * @param seqNo 账册编号
     * @return 是否存在
     */
    @GetMapping("{seqNo}/exists")
    public boolean existsBooks(@PathVariable String seqNo) {
        return booksService.exists(seqNo);
    }


    /**
     * 判断是否存在加工贸易账册
     *
     * @return seqNo-01,seqNo-02,...
     */
    @PostMapping("exists")
    public String existsBooks(@RequestBody List<String> seqNos) {
        return booksService.existsBooks(seqNos);
    }
}
